<template>
    <PageView>
        <a-card title="列表">
            <a-table
                :loading="loading"
                :columns="columns"
                :dataSource="data"
                :pagination="{total,pageSize,showSizeChanger,current}"
                @change="changePagination"
                bordered :scroll="{x:true}">
            </a-table>
        </a-card>
    </PageView>
</template>

<script type="text/jsx">
    import Member from '../../api/Member'
    export default {
        name: 'teamCaptainDetails',
        data () {
            return {
                loading: true,
                columns: [
                    {
                        title: '账号',
                        dataIndex: 'username',
                        customRender: (v) => <a>{v}</a>
                    },
                    {
                        title: '财务种类',
                        dataIndex: 'type_name',
                    },
                    {
                        title: '收支',
                        dataIndex: 'sz_type_name',
                        customRender: (v) => {
                            return <a-badge status={v==="收入"?'success':'error'} text={v}/>
                        }
                    },
                    {
                        title: '数额',
                        dataIndex: 'money',
                    },
                    {
                        title: '内容',
                        dataIndex: 'content',
                    },
                    {
                        title: '创建时间',
                        dataIndex: 'add_time',
                        customRender: (v) => this.timeOne(v)
                    },
                ],
                data: [],
                total: 0,
                pageSize: 10,
                current: 1,
                showSizeChanger: true,
                uid:null,
            }
        },
        activated () {
            this.uid = this.$route.query.uid
            this.total = 0
            this.data = []
            this.current = 1
            this.pageSize = 10
            this.showSizeChanger = true
            this.getList()
        },
        methods: {
            getList () {
                this.loading = true
                Member.getTeamCaptain({
                    page: this.current,
                    num: this.pageSize,
                    uid:this.uid
                }).then(res => {
                    this.data = res.data.map((value, key) => {
                        return { ...value, key }
                    })
                    this.loading = false
                    this.total = parseInt(res.count)
                })
            },
            changePagination (pagination) {
                Object.keys(pagination).forEach(val => {
                    this[val] = pagination[val]
                })
                this.getList()
            },
        }
    }
</script>

<style scoped lang="less">
    .inputGroup {
        > div {
            margin-bottom: 20px;
        }
    }
</style>